package com.zsc.oj.mapper;

import com.zsc.oj.model.entity.QuestionSubmit;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zsc.oj.model.vo.QuestionLanguageNum;
import com.zsc.oj.model.vo.QuestionSubmitNum;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Entity com.zsc.oj.model.entity.QuestionSubmit
 */
public interface QuestionSubmitMapper extends BaseMapper<QuestionSubmit> {

    @Select("select count(distinct questionId) as acceptNum from question_submit where userId = #{userId} && judgeInfo like '%Accepted%' order by acceptNum desc")
    int getUserAccept(Long userId);

    @Select("select questionId,count(*) as submitNum from question_submit group by questionId")
    List<QuestionSubmitNum> getQuestionSubmit();

    @Select("select language,count(language) as languageNum from question_submit where questionId = #{questionId} group by questionId,language")
    List<QuestionLanguageNum> getQuestionLanguageNum(Long questionId);

}




